<?php
class Control_AnnounceData_selectNotices {

	function selectNotices() {
		
		$tagsId = MooForm::request('tagInfo');
		
		$dirPath = ROOT_PATH . "/notices/";
		$fileList = MooFile::getFileList($dirPath);
		
		$tag = $tagsId . "_";
		$nowNotices = $dirPath . 'nowNotices.log';
		$exist = MooFile::isExists($nowNotices);
		if ($exist) {
			$info = MooFile::readAll($nowNotices);
			$infoArr = MooJson::decode($info, true);
		}
		
		$sql = "select * from @TABLE";
		$tagsInfo = MooDao::get('Tags')->getAll($sql);
		
		$tags = array();
		if($tagsInfo) {
			foreach ($tagsInfo as $key => $val) {
				$tagInfo['tagId'] 	=  $val['t_id'];
				$tagInfo['tag'] 	=  $val['t_tag'];
				$tags[] = $tagInfo;
			}
		}
		MooView::set('tags', $tags);
		
		$files = array();
		if($fileList) {
			foreach ($fileList as $key => $val) {
				if (strpos($val, $tag) === 0) {
					$file['fileName'] = $val;
					
					$nameKey = MooObj::get('Control_AnnounceData')->getNameKey($val);
					$file['nameKey'] = $nameKey;
					
					$keyTitleFile = ROOT_PATH . "/notices/" . "keyTitle.txt";
					$keyTitle = MooFile::readAll($keyTitleFile);
					$keyTitleArr = MooJson::decode($keyTitle);
					
					if($keyTitleArr[$nameKey]) {
						$title = $keyTitleArr[$nameKey];
					} else {
						$title = "";
					}
					
					$file['name'] = $title;
					
					$preName = $nowGame . "_" . $selectArea;
					if($selectLang) {
						$preName = $preName . "_" . $selectLang;
					}
					
					/* if($infoArr && $infoArr[$preName] && $infoArr[$preName] == $val) {
						// 在线上
						$file['isOnline'] = 1;
					} else {
						$file['isOnline'] = 0;
					} */
					
					$files[] = $file;
				}
			}
		}
		
		MooView::set('filList', $files);
		MooView::set('nowTagId', $tagsId);
		
		MooView::render('notices');
	}
}